﻿using System;
using System.Data;
using System.Configuration;
using TA.JSON;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.ComponentModel;


namespace TA.Turbo.Controls
{
	/// <summary>
	/// Specifies the options for displaying a certain kind of pager buttons.
	/// </summary>
	public class PagerElement : StyledLabelElement
	{
		#region PUBLIC
		#region INIT
		/// <summary>
		/// Ctor.
		/// </summary>
		public PagerElement()
		{
			this.Href = "";
			this.HrefJS = "";
		}
		#endregion
		#region PROPS
		/// <summary>
		/// Will be used for the HREF attribute of the pager link. If blank, the default action (switching pages) will be performed.
		/// </summary>
		[DefaultValue("")]
		[NotifyParentProperty(true)]
		public string Href { get; set; }
		/// <summary>
		/// Will be used for the JavaScript-enabled HREF attribute of the pager link. If blank, the default action (switching pages) will be performed.
		/// </summary>
		[DefaultValue("")]
		[NotifyParentProperty(true)]
		public string HrefJS { get; set; }
		#endregion
		#endregion
		#region INTERNAL
		#region METHODS
		/// <summary>
		/// SerializeContents.
		/// </summary>
		/// <param name="jw"></param>
		public override void SerializeContents(JsonWriter jw)
		{
			base.SerializeContents(jw);

			if (!string.IsNullOrEmpty(this.Href))
			{
				jw.PropertyName("H");
				jw.Value(this.Href);
			}

			if (!string.IsNullOrEmpty(this.HrefJS))
			{
				jw.PropertyName("HJ");
				jw.Value(this.HrefJS);
			}
		}
		/// <summary>
		/// IsDirty.
		/// </summary>
		[Browsable(false)]
		public override bool IsDirty
		{
			get
			{
				return
					base.IsDirty
					||
					!string.IsNullOrEmpty(this.Href);
			}
		}
		/// <summary>
		/// DeserializeContent.
		/// </summary>
		/// <param name="jr"></param>
		/// <param name="prShortName"></param>
		public override void DeserializeContent(IJsonReader jr, string prShortName)
		{
			base.DeserializeContent(jr, prShortName);

			switch (prShortName)
			{
				case "H":
					this.Href = (string)jr.Value;
					break;
			}
		}
		#endregion
		#endregion

	}
}